<?php
	require_once 'Connect.class.php';
	require_once 'DanhMuc.class.php';
	/**
	* 
	*/
	class NamHoc extends DanhMuc
	{
		
		public function __construct()
		{
			# code...
		}
		public function getInfo($manh){

			$conn= new Connect();

			$conn->Query("SELECT * FROM tbl_nam_hoc WHERE manh=".$manh."; ");	

			while ($row=$conn->Fetch()) {	

				$this->ma=$row['maNH'];
				
				$this->ten=$row['tenNH'];
			}
			// dong ket noi
			$conn->close();
		}
		public function capnhat(){
			$sql="UPDATE tbl_nam_hoc SET tenNH='".$this->ten."' WHERE maNH=".$this->ma."";
			
			$conn=new Connect();

			$conn->Query($sql);
			
			$conn->close();
		}
		public function xoa(){
			$sql="DELETE FROM tbl_nam_hoc WHERE maNH=".$this->ma."";
			$conn=new Connect();
			$conn->Query($sql);
			$conn->close();

		}
		public function them(){

			$sql="INSERT INTO tbl_nam_hoc(tenNH) values('".$this->ten."')";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();
			
		}
		public function ds(){
			$ds=array();
			$conn= new Connect();
			$conn->Query("SELECT * FROM tbl_nam_hoc");
			$index=0;
			while ($row=$conn->Fetch()) {
				$nh= new NamHoc();
				$nh->setMa($row['maNH']);
				$nh->setTen($row['tenNH']);
				$ds[$index]=$nh;
				$index++;
			}
			// dong ket noi
			$conn->close();
			return $ds;
		}
	}
